<template>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        商品管理
        <small>管理您仓库中的商品</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-archive"></i> 商品管理</a></li>
        <li class="active">添加商品</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">添加商品</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <form role="form">
                <!-- text input -->
                <div class="form-group">
                  <label for="productId">商品编号</label>
                  <input id="productId" class="form-control" placeholder="请输入商品编号" type="text">
                </div>
                <div class="form-group">
                  <label for="productName">商品名称</label>
                  <input id="productName" class="form-control" placeholder="请输入商品名称" type="text">
                </div>
                <div class="form-group">
                  <label for="productPrice">设置价格</label>
                  <input id="productPrice" class="form-control" placeholder="请输入商品价格" type="number">
                </div>
                <div>
                  <p id="message" class="alert alert-danger hidden">message</p>
                </div>
              </form>
            </div>
            <div class="box-footer">
              <button class="btn btn-primary" @click="add">点击提交</button>
            </div>
            <!-- /.box-body -->
          </div>
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
</template>

<script>
export default {
  name: "AddProduct",
  methods: {
    add() {
      var productId = document.getElementById("productId");
      var produceName = document.getElementById("productName");
      var productPrice = document.getElementById("productPrice");
      if (productId.value === "" || produceName.value === "" || productPrice.value === "") {
        this.$message.warning("商品信息不得为空");
      } else {
        this.GLOBAL.appData.productList.push({
          "index": this.GLOBAL.appData.productList.length,
          "id": productId.value,
          "name": produceName.value,
          "count": 0,
          "unsell": 0,
          "price": productPrice.value,
        })
        this.$message.info("修改成功（模拟操作）");
        this.$router.push("/main/productData");
      }
    }
  }
}
</script>

<style scoped>

</style>